package com.nl.gen.core;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * 框架层模版支持 dubbo、springCloud.
 *
 * @author zenghao
 */
@Getter
@AllArgsConstructor
public enum FrameworkEnum {

    DUBBO("dubbo"),
    SPRING_CLOUD("springCloud");

    private final String value;

    /**
     * 校验配置的类型是否支持，若不支持则使用 dubbo.
     *
     * @param framework framework
     * @return String
     */
    public static String check(final String framework) {
        boolean has = Stream.of(FrameworkEnum.values()).anyMatch(e -> e.getValue().equalsIgnoreCase(framework));
        return has ? framework : DUBBO.getValue();
    }
}
